﻿@using Nop.Core.Domain.Customers
@using Nop.Core.Domain.Localization
@using Nop.Web.Framework.UI;
@using Nop.Core;
@using Nop.Core.Domain.Common;
@using Nop.Services.Security;
@{
    var currentCustomer = this.WorkContext.CurrentCustomer;
    var usernamesEnabled = EngineContext.Current.Resolve<CustomerSettings>().UsernamesEnabled;
    var currentVersion = NopVersion.CurrentVersion;
    var kendoVersion = "2014.1.318";
    var supportRtl = EngineContext.Current.Resolve<IWorkContext>().WorkingLanguage.Rtl &&
        !EngineContext.Current.Resolve<LocalizationSettings>().IgnoreRtlPropertyForAdminArea;
        
        
    //CSS resources
    Html.AppendCssFileParts(string.Format("~/Content/kendo/{0}/kendo.rtl.min.css", kendoVersion));
    Html.AppendCssFileParts(string.Format("~/Content/kendo/{0}/kendo.default.min.css", kendoVersion));
    Html.AppendCssFileParts(string.Format("~/Content/kendo/{0}/kendo.common.min.css", kendoVersion));
    Html.AppendCssFileParts("~/Content/jquery-ui-themes/smoothness/jquery-ui-1.10.3.custom.min.css");
    if (supportRtl)
    {
        Html.AppendCssFileParts("~/Administration/Content/styles.rtl.css");
    }
    else
    {
        Html.AppendCssFileParts("~/Administration/Content/styles.css");
    }

    Html.AppendScriptParts(string.Format("~/Scripts/kendo/{0}/kendo.web.min.js", kendoVersion));
    Html.AppendScriptParts("~/Scripts/admin.common.js");
    Html.AppendScriptParts("~/Scripts/jquery-migrate-1.2.1.min.js");
    Html.AppendScriptParts("~/Scripts/jquery-ui-1.10.3.custom.min.js");
    Html.AppendScriptParts("~/Scripts/jquery.validate.unobtrusive.min.js");
    Html.AppendScriptParts("~/Scripts/jquery.validate.min.js");
    Html.AppendScriptParts("~/Scripts/jquery-1.10.2.min.js");

    //page title
    string adminPageTitle = "";
    if (!String.IsNullOrWhiteSpace(ViewBag.Title))
    {
        adminPageTitle = ViewBag.Title + " / ";
    }
    adminPageTitle += T("Admin.PageTitle").Text;

    //has "Manage Maintenance" permission?
    var canManageMaintenance = EngineContext.Current.Resolve<IPermissionService>()
        .Authorize(StandardPermissionProvider.ManageMaintenance);

    //X-UA-Compatible tag
    var commonSettings = EngineContext.Current.Resolve<CommonSettings>();
    if (commonSettings.RenderXuaCompatible)
    {
        Html.AppendHeadCustomParts(string.Format("<meta http-equiv=\"X-UA-Compatible\" content=\"{0}\"/>", commonSettings.XuaCompatibleValue));
    }
}
<!DOCTYPE html>
<html @(supportRtl ? Html.Raw("dir=\"rtl\"") : null)>
    <head>
        <title>@adminPageTitle</title>
        <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
        @Html.NopHeadCustom()
        @Html.NopCssFiles(this.Url, ResourceLocation.Head)
        @Html.NopScripts(this.Url, ResourceLocation.Head)
    </head>
    <body @(supportRtl ? Html.Raw("class=\"k-rtl\"") : null)>
        <div id="ajaxBusy">
            <span>&nbsp;</span>
        </div>
        <div class="master-wrapper-page k-content">
            <div class="master-wrapper-content">
                @if (IsSectionDefined("header"))
                {
                    @RenderSection("header")
                }
                else
                {
                    <script type="text/javascript">
                        $(document).ready(function () {
                            $("#restart-application").click(function (e) {
                                showThrobber('@Html.Raw(HttpUtility.JavaScriptStringEncode(T("Admin.Header.RestartApplication.Progress").Text))');
                            });
                        });
                    </script>
                    <div class="header">
                        <div class="logo">
                        </div>
                        @Html.Widget("admin_header_before")
                        <div class="languageselector">
                            @Html.Action("LanguageSelector", "Common")
                        </div>
                        @Html.Widget("admin_header_middle")
                        <div class="links">
                            @Html.ActionLink(T("Admin.Header.PublicStore").Text, "Index", "Home", new { area = "" }, null)
                            @if (canManageMaintenance)
                            {
                                <span class="separator">|</span>
                                @Html.ActionLink(T("Admin.Header.ClearCache").Text, "ClearCache", "Common")
                                <span class="separator">|</span>
                                @Html.ActionLink(T("Admin.Header.RestartApplication").Text, "RestartApplication", "Common", null, new { id = "restart-application" })
                            }
                        </div>
                        <div class="login-info">
                            @if (currentCustomer != null && currentCustomer.IsRegistered())
                            {
                                @String.Format(T("Admin.Header.LoggedInAs").Text, usernamesEnabled ? currentCustomer.Username : currentCustomer.Email)
                                <text>, </text> @Html.ActionLink(T("Admin.Header.Logout").Text, "Logout", "Customer", new { area = "" }, null)
                            }
                        </div>
                        <div class="version">
                            <span>nopCommerce @currentVersion</span>
                        </div>
                        @Html.Widget("admin_header_after")
                    </div>
                }
                @if (IsSectionDefined("headermenu"))
                {
                    @RenderSection("headermenu")
                }
                else
                {
                    <div class="header-menu">
                        @Html.Partial("Menu")
                    </div>
                }
                @if (IsSectionDefined("statusbar"))
                {
                    @RenderSection("statusbar")
                }
                else
                {
                    <div class="status-bar">
                        @(EngineContext.Current.Resolve<Nop.Services.Helpers.IDateTimeHelper>().ConvertToUserTime(DateTime.Now).ToString("f"))
                    </div>
                }
                <div class="content">
                    @Html.Partial("Notifications")
                    <div class="cph">
                        @RenderBody()
                    </div>
                </div>
                <div class="throbber">
                    <div class="curtain">
                    </div>
                    <div class="curtain-content">
                        <div>
                            <h1 class="throbber-header">Wait...</h1>
                            <p>
                                <img src="@Url.Content("~/administration/content/images/throbber-synchronizing.gif")" alt="" />
                            </p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        @Html.NopCssFiles(this.Url, ResourceLocation.Foot)
        @Html.NopScripts(this.Url, ResourceLocation.Foot)
    </body>
</html>

